package com.fly.boot;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.context.WebApplicationContext;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@SpringBootApplication
public class MainApplication implements CommandLineRunner
{
    @Autowired
    WebApplicationContext wac;
    
    public static void main(String[] args)
    {
        SpringApplication.run(MainApplication.class, args);
    }
    
    @Override
    public void run(String... args)
        throws Exception
    {
        log.info("★★★★★★★★ WebApplicationContext = {}", wac);
        AtomicInteger index = new AtomicInteger();
        Stream.of(wac.getBeanDefinitionNames()).forEach(name -> log.info("{}.\t{}", index.incrementAndGet(), name));
    }
}